package org.coderk.mybatis.controller.transaction;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import java.time.LocalDateTime;

/**
 * @author: TanJingyu
 * @create: 2021-06-29 16:30
 **/
@Service
public class Bservice {
    @Autowired
    private JdbcTemplate jdbcTemplate;

    @Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
    public void b() {
        jdbcTemplate.update("INSERT INTO b (name,time) VALUES ('李白', '" + LocalDateTime.now() + "')");
    }
}
